<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>正则表达式</title>
</head>
<body>
    <input type="text" id="username">
    <input type="button" value="提交" onclick="check()">

    <script>
        function check(){
            let username = document.getElementById("username").value;
            //定义一个正则对象
            let reg = /^[a-z][0-9]{4}$/;
            if(reg.test(username)){
                alert("验证成功!");
            }else{
                alert("验证失败!");
            }
        }
    </script>
</body>
</html>